package com.com.unit2.gram;

public class CallPackage extends AbstractPackage implements OnlineService,CallService{
    // 1.私有化独有的成员变量
    private int talkTime;   // 通话时长
    private int messageNum; // 短信条数
    private int monthlyRate;// 每月资费


    // 3.在构造方法中调用set方法并进行合理值的判断
    public CallPackage() {
    }

    public CallPackage(int monthlyRate, int talkTime, int messageNum, int monthlyRate1) {
        super(monthlyRate);
        setTalkTime(talkTime);
        setMessageNum(messageNum);
    }

    // 2.提供公有的get和set方法并进行合理值的判断
    public int getTalkTime() {
        return talkTime;
    }

    public void setTalkTime(int talkTime) {
        if(talkTime>=0) {
            this.talkTime = talkTime;
        } else {
            System.out.println("通话时长不合理哦！");
        }
    }

    public int getMessageNum() {
        return messageNum;
    }

    public void setMessageNum(int messageNum) {
        if(messageNum>=0) {
            this.messageNum = messageNum;
        } else {
            System.out.println("短信条数不合理哦！");
        }
    }

    public int getMonthlyRate() {
        return monthlyRate;
    }

    public void setMonthlyRate(int monthlyRate) {
        if(monthlyRate>=0) {
            this.monthlyRate = monthlyRate;
        } else {
            System.out.println("每月资费不合理哦！");
        }
    }

    @Override
    public void onlineService(int netFlow, SIMCard simCard) {
        simCard.show();
    }

    @Override
    public void callService(int talkTime, SIMCard simCard) {
        simCard.show();
        setTalkTime(talkTime);
    }

    @Override
    public void show() {
        System.out.println("====通话套餐类====");
        System.out.println("通话时长：" + getTalkTime());
        System.out.println("短信条数：" + getMessageNum());
        System.out.println("每月资费：" + getMonthlyRate());
    }
}
